<?php
declare (strict_types=1);

namespace app\exam\logic;

use app\common\exception\LogicException;
use app\exam\model\OptionCompletion as OptionCompletionModel;


/**
 * 试题逻辑
 */
class OptionCompletion extends OptionCompletionModel
{

	/**
	 * 获取试题选项
	 * Author 亓官雨树<lucky.max@foxmail.com>
	 * Date 2021-02-04
	 * @param  integer $topic_id   [description]
	 * @param  integer $topic_type [description]
	 * @return [type]              [description]
	 */
	public function getTopicOptions($topic_id = 0)
	{
		$options = $this->field('id,number,value,sort')->whereTopicId($topic_id)->select();
		
		$return = [];

		foreach ($options as $key => $option) {
			$return[$option->number]['number'] = $option->number;
			$return[$option->number]['values'][] = $option->value;
		}

		return array_values($return);
	}

}